<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>

<body>
  <input type="checkbox">
  <input type="checkbox">
  <input type="checkbox">
  <input type="checkbox">
  <input type="checkbox">
  <script src="./jquery-3.4.1.min.js"></script>
  <script>
    // 封装方法 调用 让所有复选框选中
    // jQuery.fn.extend(object) 给jq的元素扩展方法
    jQuery.fn.extend({
      // 方法1
      checkall: function () {
        // this--代表当前的元素
        this.each(function (index, ele) {
          ele.checked = true
        })
      },
      // 方法2
      uncheck: function () {
        this.each(function (index, ele) {
          ele.checked = false
        })
      }
    })
    // 调用
    $(":checkbox").checkall()
    $(":checkbox").uncheck()
    var date = new Date();
    date.setDate(27)
    document.cookie = "username=zhang; exprise=" + date.toUTCString()
    document.cookie = "age=34; exprise=" + date.toUTCString()
    document.cookie = "sex=1; exprise=" + date.toUTCString()
    // jQuery.extend({}) 扩展全局工具类
    jQuery.extend({
      getcookie: function (name) { //获取cookie的方法
        var cookie = document.cookie;
        console.log(cookie)
        var cookiearr = cookie.split("; ");
        for (var i = 0; i < cookiearr.length; i++) {
          var newarr = cookiearr[i].split("=");
          if (name == newarr[0]) {
            return newarr[1]
          }
        }
      },
      max: function (a, b) {
        if (a > b) {
          return a
        } else {
          return b
        }
      },
      min: function (a, b) {
        if (a < b) {
          return a
        } else {
          return b
        }
      }
    })
    console.log($.getcookie("username"))
    console.log($.max(123123, 324212))
  </script>
</body>

</html>